package com.leo.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author du
 */
public class HttpChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // Netty提供的http编解码器 (内部基于lineParser/headerParser)
        ch.pipeline().addLast("MyHttpServerCodec", new HttpServerCodec());

        // 加一个自己的handler处理器
        ch.pipeline().addLast("MyHttpServerHandler", new HttpServerHandler());

        System.out.println("pipeline初始化完毕");
    }
}
